home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / U-Z / VideoToolBox Folder / Utilities / Quick3 / Quick3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-23  |  1.9 KB  |  60 lines  |  [TEXT/KAHL]

  1. /* Quick3.h
  2. HISTORY:
  3. 3/10/92 dgp    Cast PARAMS to be a short int.
  4.             If appropriate, use the 68881 log and exp instructions for speed.
  5.             For speed, defined exp10(), and use exp and log to compute pow.
  6.             These changes speed up the computation enormously, perhaps 50-fold,
  7.             yet when run on "sample.data" the resulting "sample.fit" is unchanged.
  8. */
  9. #pragma once    /* prevent multiple inclusions of this file */
  10. #include <math.h>
  11. #include <stdio.h>    /* needed for prototypes */
  12. #include <stdlib.h>
  13. #define MAX_CONTRASTS 200
  14. #define ILLEGAL_PARAMETERS -1.0    /* unique value indicating parameters out of bounds */
  15. #define MACINTOSH 1
  16. #include "mc68881.h"
  17. #if THINK_C && mc68881
  18.     #define exp _exp    /* use fast 68881 instruction instead of SANE */
  19.     #define log _log    /* use fast 68881 instruction instead of SANE */
  20. #endif
  21. #ifndef exp10
  22. #define exp10(x) exp(LOG10*(x))            /* faster than pow(10.0,x) */
  23. #endif
  24. #define pow(x,y) exp(log(x)*(y))        /* faster by use of 68881 instructions */
  25. #if !defined(LOG10)
  26.     #define LOG10    2.30258509299404568402    /* computed in Mathematica */
  27. #endif
  28.  
  29. typedef struct {
  30.     double contrast;
  31.     long trials;
  32.     long correct;
  33. } contrastRecord;
  34.  
  35. typedef struct {
  36.     int contrasts;
  37.     contrastRecord c[MAX_CONTRASTS];    /* an array of records is easier to sort */
  38. } dataRecord;
  39.  
  40. typedef struct {
  41.     double logAlpha;
  42.     double beta;
  43.     double gamma;
  44.     double delta;
  45. } paramRecord;
  46.  
  47. #define PARAMS ((short)(sizeof(paramRecord)/sizeof(double)))
  48.  
  49. typedef double (*PsychometricFunctionPtr)(double contrast,paramRecord *paramPtr);
  50.  
  51. double Weibull(double contrast,paramRecord *paramPtr);
  52. double LogLikelihood(dataRecord *data,paramRecord *params,
  53.     PsychometricFunctionPtr PsychFun);
  54. double PsychometricFit(paramRecord *paramPtr
  55.     ,PsychometricFunctionPtr PsychFun
  56.     ,dataRecord *dataPtr,double *logLikelihoodPtr,int degreesOfFreedom
  57.     ,double *chiSquarePtr,int *chiSquareDFPtr);
  58. void MonotonicFit(dataRecord *data,double *logLikelihoodPtr,int *degreesOfFreedomPtr);
  59. void SortAndMergeContrasts(dataRecord *dataPtr);
  60.